<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        function Person(name, age, gender) {
            this.name = name;
            this.age = age;
            this.gender = gender;
            this.sayName = function() {
                alert(this.name);
            }

        }


        function Dog(name) {
            this.name = name;
        }


        var per1 = new Person("孙悟空", 18, "男");
        var per2 = new Person("孙悟空", 18, "男");

        var dog = new Dog("哮天犬");


        console.log(per1);
        console.log(per2);
        // 可以查看dog实例是否是Person构造方法所创建的
        console.log(dog instanceof Person);
    </script>
</body>

</html>